Let’s start the task of future sales prediction with machine learning by importing the necessary Python libraries and the dataset:

Let’s have a look at whether this dataset contains any null values or not:

So this dataset doesn’t have any null values. Now let’s visualize the relationship between the amount spent on advertising on TV and units sold:

Now let’s visualize the relationship between the amount spent on advertising on newspapers and units sold:

Now let’s visualize the relationship between the amount spent on advertising on radio and units sold:

Out of all the amount spent on advertising on various platforms, I can see that the amount spent on advertising the product on TV results in more sales of the product. Now let’s have a look at the correlation of all the columns with the sales column:

Future Sales Prediction Model

Now in this section, I will train a machine learning model to predict the future sales of a product. But before I train the model, let’s split the data into training and test sets:

Now let’s train the model to predict future sales:

Now let’s input values into the model according to the features we have used to train it and predict how many units of the product can be sold based on the amount spent on its advertising on various platforms:

Summary

So this is how we can train a machine learning model to predict the future sales of a product. Predicting the future sales of a product helps a business manage the manufacturing and advertising cost of the product